package com.qire.manhua.controller;

import android.view.View;

import com.qire.common.basic.ObjectUtil;
import com.qire.manhua.BR;
import com.qire.manhua.databinding.FragmentRecommendGirlsBinding;
import com.qire.manhua.fragment.RecommendGirlsFragment;
import com.qire.manhua.model.viewModel.impl.RecommendGirlsViewModel;
import com.qire.manhua.model.viewModel.impl.RecommendGirlsViewModel.GirlsSlideZoneViewModel.GirlsBannerItemViewModel;

import androidx.annotation.NonNull;
import androidx.databinding.ViewDataBinding;

public class RecommendGirlsController extends RecommendModuleController<RecommendGirlsFragment> {

    private RecommendGirlsViewModel viewModel;

    public RecommendGirlsController(@NonNull RecommendGirlsFragment lifecycleOwner) {
        super(lifecycleOwner);
    }

    @Override
    protected void bindView() {
        FragmentRecommendGirlsBinding viewDataBinder = owner.viewDataBinder();
        if(viewDataBinder != null) {
            viewDataBinder.setRecommendGirlsController(this);
        }
    }

    @Override
    public void bindVariable(ViewDataBinding viewBind) {
        super.bindVariable(viewBind);
        viewBind.setVariable(BR.recommendGirlsController, this);
    }

    @Override
    protected void onCleared() {
        super.onCleared();
        this.viewModel = null;
    }

    public void onAddition(RecommendGirlsViewModel viewModel) {
        this.viewModel = viewModel;
    }

    /*************************************************************************************************************************/

    public void bannerOnPageSelected(int position) {
        if(ObjectUtil.nonNull(viewModel)) {
            viewModel.changeBannerBackground(position);
        }
    }

    /**
     * 点击banner广告
     * @param view
     */
    public void onBannerItemClick(View view) {
        GirlsBannerItemViewModel bannerItemViewModel = (GirlsBannerItemViewModel) view.getTag();
        bannerItemViewModel.doAction();
    }

    public void errorReloadBtnOnClick(View view){
//        presenter().loadPageData();
    }

}
